/*
*Copyright (c) Nikhil Jain.
*Project ICARUS, communications and 
*artificial intelligence.
*/



/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
 */
package ai.rrt;

//~--- JDK imports ------------------------------------------------------------

import javax.vecmath.Vector3d;

/**
 *
 * @author Nikzzay
 */
public class Node {
    double   cost               = Double.MAX_VALUE;
    double   pathLengthFromRoot = -1;
    Vector3d coords;

    public Node() {
        this.coords = new Vector3d();
    }

    public Node(Vector3d coords) {
        this.coords = new Vector3d(coords);
    }

    public void setCoordinates(Vector3d v) {
        coords.set(v.x, v.y, v.z);
    }

    public void setPathLengthFromRoot(double pathLength) {
        pathLengthFromRoot = pathLength;
    }

    public void setCost(double cost) {
        this.cost = cost;
    }

    public Vector3d getCoordinates() {
        return new Vector3d(coords);
    }

    public double pathLengthFromRoot() {
        return pathLengthFromRoot;
    }

    public double cost() {
        return cost;
    }

    @Override
    public int hashCode() {
        int hash = 3;

        hash = 53 * hash + (int) (Double.doubleToLongBits(coords.x) ^ (Double.doubleToLongBits(coords.x) >>> 32));
        hash = 53 * hash + (int) (Double.doubleToLongBits(coords.y) ^ (Double.doubleToLongBits(coords.y) >>> 32));
        hash = 53 * hash + (int) (Double.doubleToLongBits(coords.z) ^ (Double.doubleToLongBits(coords.z) >>> 32));

        return hash;
    }

    @Override
    public boolean equals(Object o) {
        if (o instanceof Node) {
            Node N = (Node) o;

            return (coords.x == N.coords.x) && (coords.y == N.coords.y) && (coords.z == N.coords.z);
        }

        return false;
    }
}


//~ Formatted by Jindent --- http://www.jindent.com
